package cn.home.fenni.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.home.common.annotation.Log;
import cn.home.common.core.controller.BaseController;
import cn.home.common.core.domain.AjaxResult;
import cn.home.common.enums.BusinessType;
import cn.home.fenni.domain.HomeServiceTags;
import cn.home.fenni.service.IHomeServiceTagsService;
import cn.home.common.utils.poi.ExcelUtil;
import cn.home.common.core.page.TableDataInfo;

/**
 * 服务包标签Controller
 * 
 * @author gm
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/tags/tags")
public class HomeServiceTagsController extends BaseController
{
    @Autowired
    private IHomeServiceTagsService homeServiceTagsService;

    /**
     * 查询服务包标签列表
     */
    @PreAuthorize("@ss.hasPermi('tags:tags:list')")
    @GetMapping("/list")
    public TableDataInfo list(HomeServiceTags homeServiceTags)
    {
        startPage();
        List<HomeServiceTags> list = homeServiceTagsService.selectHomeServiceTagsList(homeServiceTags);
        return getDataTable(list);
    }

    /**
     * 导出服务包标签列表
     */
    @PreAuthorize("@ss.hasPermi('tags:tags:export')")
    @Log(title = "服务包标签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HomeServiceTags homeServiceTags)
    {
        List<HomeServiceTags> list = homeServiceTagsService.selectHomeServiceTagsList(homeServiceTags);
        ExcelUtil<HomeServiceTags> util = new ExcelUtil<HomeServiceTags>(HomeServiceTags.class);
        util.exportExcel(response, list, "服务包标签数据");
    }

    /**
     * 获取服务包标签详细信息
     */
    @PreAuthorize("@ss.hasPermi('tags:tags:query')")
    @GetMapping(value = "/{tagId}")
    public AjaxResult getInfo(@PathVariable("tagId") Long tagId)
    {
        return success(homeServiceTagsService.selectHomeServiceTagsByTagId(tagId));
    }

    /**
     * 新增服务包标签
     */
    @PreAuthorize("@ss.hasPermi('tags:tags:add')")
    @Log(title = "服务包标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HomeServiceTags homeServiceTags)
    {
        return toAjax(homeServiceTagsService.insertHomeServiceTags(homeServiceTags));
    }

    /**
     * 修改服务包标签
     */
    @PreAuthorize("@ss.hasPermi('tags:tags:edit')")
    @Log(title = "服务包标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HomeServiceTags homeServiceTags)
    {
        return toAjax(homeServiceTagsService.updateHomeServiceTags(homeServiceTags));
    }

    /**
     * 删除服务包标签
     */
    @PreAuthorize("@ss.hasPermi('tags:tags:remove')")
    @Log(title = "服务包标签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tagIds}")
    public AjaxResult remove(@PathVariable Long[] tagIds)
    {
        return toAjax(homeServiceTagsService.deleteHomeServiceTagsByTagIds(tagIds));
    }
}
